<?php

class Nld_Html
{
	static function error($error, $sprintf = '%2$s', $spread = "<br />")
	{
		$result = array();
		if(empty($error))
			return '';
		foreach($error as $k => $v)
		{
			$result[$k] = sprintf($sprintf, $k, $v);
		}
		return @implode($spread, $result);
	}
	static function notify($errors, $spread = "<br />")
	{
		$result = array();
		if(is_array($errors))
		foreach($errors as $error)
		{
			$class = 'success';
			if(preg_match('/^\w+|/', $error, $matches))
			{
				$class = $matches[0];
				$error = preg_replace('/^(\w+\|)/','', $error);
			}
			$result[] = '<div class="alert alert-'.$class.' animate6 bounceIn">'.
			'<a class="close" data-dismiss="alert">&times;</a>'.$error.'</div>';
		}
		return @implode($spread, $result);
	}
}